package com.zlq.login.controller;



import com.zlq.login.dao.UserDaoLo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/listController")
public class ListController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=Utf-8");


        List users = null;
        try {
            users = new UserDaoLo().selectAll();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(users);
        req.getSession().setAttribute("users", users );
        resp.sendRedirect("/static/listUser.jsp");
    }
}
